home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 43 / Mac Magazin and MacEasy Magazine CD - Issue 43.iso / Software / Mobiles Büro / Newton / Newton Entwickler / Newt Development Env. 3.4 ƒ / applic2.nwt < prev    next >
Text File  |  1998-01-25  |  6KB  |  223 lines

  1. Notes
  2. {labels: 'NIL, viewFont: 10241} // nil=Unfiled, or specify a folder, e.g., 'Business.  remove viewFont for current Styles default
  3. //ERASE! in order to erase existing entries in this folder first
  4.  
  5. applic2.nwt -- Sloup format
  6. 25 Jan 1998
  7. Copyright 1994-98 S. Weyer.  All Rights Reserved Worldwide.
  8. To be distributed only with NewtDevEnv
  9.  
  10. expanded MyApp example using more prototypes
  11. see applic0.nwt or NewtATut for introductory example
  12. (that includes Rotate, info button, about box, help)
  13.  
  14. see applic2.pkg for Paperback version of this file
  15.  
  16. see applic3.nwt for same version as applic2.nwt but using
  17. earlier, more direct :addApp, :addStep syntax
  18. ----------
  19. MyApp2
  20. //:doObj('buildCO,'MyApp2)
  21. //:doObj('add,'MyApp2)
  22. //:doObj('remove,'MyApp2)
  23. {_proto: protoApp,
  24. title: "Hello World -- on Steroids",
  25. _package: {shortTitle: "Hello2"},
  26. }
  27. ----------
  28. MyApp2.protoNumberInputLine
  29. {_proto: protoInputLine,
  30. text: "enter a number",
  31. value: 0,
  32. viewFlags: 10753, //vVisible + vClickable + vGesturesAllowed + vNumbersAllowed
  33. viewChangedScript: func(slot,view)
  34.     if slot='text
  35.     then begin
  36.         value := StringToNumber(text);
  37.         if not value then value := 0;
  38.         if aTotal exists then aTotal:update();
  39.         end,
  40. viewSetupFormScript: func()
  41.     begin
  42.         self.text := clone(text);
  43.         self.value := 0;
  44.         inherited:?viewSetupFormScript();
  45.     end,
  46. }
  47. ----------
  48. MyApp2+float
  49. {_proto: protoFloatNGo,
  50. viewBounds: RelBounds(20,50,150,90),
  51. }
  52. ----------
  53. MyApp2.float+aboutText
  54. {viewclass: clParagraphView,
  55. text: "This wonderful application from the \"kitchen sink school of user interface design\" created by "&
  56.     :GetUserConfig('name) &      // the developer's name
  57.     ", with the help of Newt, the lizard wizard",
  58. viewFlags: 3, //vReadOnly+vVisible,
  59. viewBounds: RelBounds(5,5,140,80), // relative to aFloat
  60. }
  61. ----------
  62. MyApp2+button
  63. {_proto: protoTextButton,
  64. text: "About",
  65. viewBounds: RelBounds(20,30,40,16),
  66. buttonClickScript: func()
  67.     if float exists
  68.     then float:open()
  69.     else PlaySound(@102), // ROM_funbeep
  70. }
  71. ----------
  72. MyApp2+num1
  73. {_proto: protoNumberInputLine, // use user prototype defined in app
  74. text: "first number", // needs to be set so protos don't share text string
  75. viewBounds: RelBounds(130,20,100,20),
  76. }
  77. ----------
  78. MyApp2+num2
  79. {_proto: protoNumberInputLine,
  80. text: "second number",
  81. viewBounds: RelBounds(130,45,100,20),
  82. }
  83. ----------
  84. MyApp2+aTotal
  85. {_proto: protoStaticText,
  86. text: "Total",
  87. vars: ['num1, 'num2,], // same names as two fields
  88. viewBounds: RelBounds(130,80,100,16),
  89. update: func()
  90.     begin
  91.         local tot := 0, field;
  92.         foreach field in vars // add up num1.value+num2.value etc.
  93.         do tot := tot + GetVariable(self,field).value;
  94.         if round exists and round.viewValue
  95.         then tot := RIntToL(tot);
  96.         SetValue(self,'text,NumberStr(tot));
  97.     end,
  98. }
  99. ----------
  100. MyApp2+round
  101. {_proto: protoRCheckbox, // checkbox on right & text on left
  102. text: "Round?",
  103. indent: 40,
  104. viewBounds: RelBounds(10,78,50,16), 
  105. valueChanged: func() aTotal:update(),
  106. }
  107. ----------
  108. MyApp2+aTextval
  109. {_proto: protoStaticText,
  110. text: "xxx",
  111. viewBounds: RelBounds(150,240,100,16),
  112. }
  113. ----------
  114. MyApp2+labelLine
  115. {_proto: protoLabelInputLine,
  116. viewBounds: RelBounds(10,110,200,20),
  117. label: "a label",
  118. textSetup: func() clone("some string"), // initial value
  119. labelCommands: ["A", "B", "C"],  // optional
  120. textChanged: func()
  121.     SetValue(aTextval,'text,entryLine.text),
  122. }
  123. ----------
  124. MyApp2+picker
  125. {_proto: protoLabelPicker,
  126. text: "picker",
  127. viewBounds: RelBounds(10,140,100,16), 
  128. labelCommands: ["one", "two", "three",],
  129. labelActionScript: func(cmd)
  130.     SetValue(aTextval,'text,labelCommands[cmd]),
  131. }
  132. ----------
  133. MyApp2+slider
  134. {_proto: protoSlider,
  135. viewBounds: RelBounds(10,160,100,12),
  136. minValue: 1,
  137. maxValue: 3,
  138. viewSetupFormScript: func()
  139.     viewValue := (maxValue+minValue)/2,
  140. changedSlider: func()
  141.     SetValue(aTextval,'text,NumberStr(viewValue)),
  142. }
  143. ----------
  144. MyApp2+radiobuttons
  145. {_proto: protoRadioCluster,
  146. viewBounds: RelBounds(150,190,100,50),
  147. clusterChanged: func()
  148.     SetValue(aTextval,'text,NumberStr(clusterValue)),
  149. }
  150. ----------
  151. MyApp2.radiobuttons+ten
  152. {_proto: protoRadioButton,
  153. text: "diez",
  154. buttonValue: 10,
  155. viewBounds: RelBounds(0,0,60,15), // relative to radiobuttons
  156. }
  157. ----------
  158. MyApp2.radiobuttons+twenty
  159. {_proto: protoRadioButton,
  160. text: "veinte",
  161. buttonValue: 20,
  162. viewBounds: RelBounds(0,15,60,15),
  163. }
  164. ----------
  165. MyApp2.radiobuttons+thirty
  166. {_proto: protoRadioButton,
  167. text: "treinta",
  168. buttonValue: 30,
  169. viewBounds: RelBounds(0,30,60,15),
  170. }
  171. ----------
  172. MyApp2+textlist
  173. {_proto: protoTextlist,
  174. viewBounds: Relbounds(150,140,60,40),
  175. viewSetupFormScript: func()
  176.     begin 
  177.         self.listItems := ["larry","moe","curly"];
  178.         //viewLines := length(listItems);
  179.         :setupList() ;
  180.         inherited:?viewSetupFormScript();
  181.     end,
  182. viewLines: 3,
  183. buttonClickScript: func(i)
  184.     SetValue(aTextval,'text,listitems[i]),
  185. }
  186. ----------
  187. MyApp2+expando
  188. {_proto: protoExpandoShell,
  189. viewBounds: RelBounds(10,185,120,70),
  190. numLines: 2,
  191. viewFormat: 337, // vfFillWhite+vfFrameBlack+vfPen=1
  192. editHeight: 46, // height of expanded field
  193. editWidth: 80,
  194. indent: 50, // left edge of value
  195. myExpandoProto:
  196.     {_proto: protoTextExpando,
  197.     label: "a label",
  198.     path: 'var,
  199.     },
  200. viewSetupFormScript: func()
  201.     begin
  202.         local i, symslot;
  203.         self.target := self;
  204.         self.lines:=array(numLines,nil);
  205.         for i:=1 to numLines
  206.         do begin
  207.             symslot := intern("var"&i);
  208.             lines[i-1]:=
  209.                 {_proto: myExpandoProto,
  210.                 label: "Field" && i,
  211.                 path: symslot,  // e.g., 'var1
  212.                 };
  213.             SetValue(self,symslot,clone(""));
  214.             end;
  215.         inherited:viewSetupFormScript();
  216.     end,
  217. FlushEdits: func() nil, //inherited:?FlushEdits(), // no method to inherit?
  218. CloseEdit: func(view) // expanded field just closed
  219.     SetValue(aTextval,'text, target.(view.path)),
  220. }
  221. ----------
  222. BYE!
  223.